# Contributor: Leo <thinkabit.ukim@gmail.com>
# Contributor: Claas Störtenbecker <claas.stoertenbecker@gmail.com>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=gopass
pkgver=1.9.2
pkgrel=0
pkgdesc="The slightly more awesome Standard Unix Password Manager for Teams. Written in Go."
url="https://www.gopass.pw"
arch="all !mips !mips64"
license="MIT"
depends="gnupg git"
makedepends="go ncurses"
source="$pkgname-$pkgver.tar.gz::https://github.com/gopasspw/gopass/archive/v$pkgver.tar.gz"
builddir="$srcdir/src/github.com/gopasspw/$pkgname"
options="chmod-clean"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"

prepare() {
	mkdir -p "$srcdir/src/github.com/gopasspw"
	mv "$srcdir/$pkgname-$pkgver" "$srcdir/src/github.com/gopasspw/gopass"
	default_prepare
}

check() {
	GOPATH="$srcdir" make test-integration
}

build() {
	GOPATH="$srcdir" make build

	for completion in bash zsh fish; do
		./gopass completion $completion > $completion.completion;
	done
}

package() {
	install -Dm755 "$builddir/$pkgname" -t "$pkgdir/usr/bin"

	install -Dm0644 "$builddir"/bash.completion \
		"$pkgdir"/usr/share/bash-completion/completions/gopass
	install -Dm0644 "$builddir"/zsh.completion \
		"$pkgdir"/usr/share/zsh/site-functions/_gopass
	install -Dm0644 "$builddir"/fish.completion \
		"$pkgdir"/usr/share/fish/completions/gopass.fish
}

sha512sums="90be234718c4c26ee6e92565ce609d5f075d5e574827e15ff57a6d9e71f1933add7d76aa26b39602d5a72485890bfe8e158dc89213098377899d0f721aacf1d7  gopass-1.9.2.tar.gz"
